package cn.classLoader;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class DefineClassLoader2 {
    //这是一个main方法,是程序的入口
    public static void main(String[] args) throws MalformedURLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        //从网络中获取字节码文件，但是报错了，明天解决
        URL url = new URL("http://localhost:8080/examples/");
        //Exception in thread "main" java.lang.UnsupportedClassVersionError
        //Student has been compiled by a more recent version of the Java Runtime (class file version 59.0)
        //应该跟我使用的javac的版本有关系。版本过高。

        URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
        System.out.println("父类加载器:"+urlClassLoader.getParent());//默认为系统加载器

        Class<?> aClass = urlClassLoader.loadClass("Student");
        Object o = aClass.newInstance();
        System.out.println(o);


    }
}
